package acm.usa2006.gnewyork;

import java.util.Scanner;

/*
 * p2542
 * Greater New York 2006
 */

public class p2542 {

	static int C, N;
	static int[] count;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		count = new int[1001];
		count[1] = 3;
		for (int i=2;i<=1000;++i) {
			count[i] = count[i-1];
			for (int j=1;j<i;++j) {
				if (gcd(i,j) == 1) {
					count[i] += 2;
				}
			}
		}
		
		
		C = scanner.nextInt();
		for (int i=1;i<=C;++i) {
			N = scanner.nextInt();
			System.out.println(i + " " + N + " " + count[N]);
		}
		
	}

	private static int gcd(int m, int n) {
		if (m == 0) {
			return n;
		}
		else {
			return gcd(n%m,m);
		}
	}

}
